package com.example.figurehecheng.controller.merchant;


import com.example.figurehecheng.common.result.PageResult;
import com.example.figurehecheng.common.result.Result;
import com.example.figurehecheng.domain.dto.HousePageDTO;
import com.example.figurehecheng.domain.dto.SaveHouseDTO;
import com.example.figurehecheng.service.IHouseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 宇科工作室
 * @since 2024-10-18
 */
@RestController("merchantHouseController")
@RequestMapping("/merchant/house")
@CrossOrigin
@RequiredArgsConstructor
@Slf4j
@Api(tags = "房间管理相关接口")
public class HouseController {

    private final IHouseService houseService;


    /**
     * 查询房间信息
     * @param housePageDTO
     * @return
     */
    @GetMapping("/selectHousePage")
    @ApiOperation("查询房间信息")
    public Result<PageResult> selectHousePage(HousePageDTO housePageDTO){
        log.info("查询房间信息：{}", housePageDTO);
        PageResult pageResult = houseService.selectHousePage(housePageDTO);
        return Result.success(pageResult);
    }

    /**
     * 添加房间信息
     * @param saveHouseDTO
     * @return
     */
    @PostMapping("/saveHouse")
    @ApiOperation("添加房间信息")
    public Result saveHouse(@RequestBody SaveHouseDTO saveHouseDTO){
        log.info("添加房间信息：{}", saveHouseDTO);
        houseService.saveHouse(saveHouseDTO);
        return Result.success();
    }

    /**
     * 修改房间
     * @param saveHouseDTO
     * @return
     */
    @PostMapping("/updateHouse")
    @ApiOperation("修改房间")
    public Result updateHouse(@RequestBody SaveHouseDTO saveHouseDTO){
        log.info("修改房间：{}", saveHouseDTO);
        houseService.updateHouse(saveHouseDTO);
        return Result.success();
    }

    /**
     * 根据id删除房间
     * @param id
     * @return
     */
    @DeleteMapping("/deleteHouse")
    @ApiOperation("根据id删除房间")
    public Result deleteHouse(@RequestBody Integer id){
        log.info("根据id删除房间：{}", id);
        houseService.deleteHouse(id);
        return Result.success();
    }

}
